﻿@using System.Reflection;
@using YUCodeGen.Utils;
@model PropertyInfo[]
@{
    Layout = null;
    ViewBag.Title = "Template";
    string cat = ViewData["cat"].ToString();
    string classname = ViewData["ClassName"].ToString();
}

<!--YuCodeGen Start Here-->

<div class="p-5">
    <h4 class="mb-4">Create a @(classname)</h4>

    <form [formGroup]="form">
        @foreach (PropertyInfo pinfo in Model)
        {
            if (cat != "create" || PageUtil.IsCreate(pinfo))
            {
                @Html.Partial("_Input", pinfo)
            }
        }
    </form>
    <div>
            @if (cat == "create")
            {
                <button (click)="createClick()" [disabled]="!form.valid" mat-raised-button color="primary" class="m-1"><mat-icon>create</mat-icon> Create</button>
            }
            else
            {
                <button (click)="saveClick()" [disabled]="!form.valid" mat-raised-button color="primary"><mat-icon>save</mat-icon> Save</button>
            }
                <button (click)="cancelClick()" mat-raised-button class="m-1"><mat-icon>cancel</mat-icon>Cancel</button>
    </div>
    

</div>

<!-- <p>
    {{form.value|json}}
</p>
<p>
    {{form.status}}
</p> -->
<!--YuCodeGen End Here-->
